package com.chanyachting.emall.action.yellow;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.chanyachting.emall.domain.Company;
import com.chanyachting.emall.serviceImpl.CompanyServiceImpl;

public class CompanyProductDetailAction extends Action {
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		String companyId = request.getParameter("comanyId");
		
		CompanyServiceImpl naservice = new CompanyServiceImpl();
		List companyList = null;
		Company company = null;
		if (null != companyId && !"".equals(companyId)) {
			companyList = naservice.getCompanyById(companyId + "");
		}

		if (null != companyList && companyList.size() > 0) {
			company = (Company) companyList.get(0);
		}

		request.setAttribute("company", company);
		
		//TODO set product detail
		request.setAttribute("productDetail", "TODO");

		return mapping.findForward("readProductDetail");

	}
}
